import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { basMesOperListData } from '../../../../api/bas/mes/oper/basMesOper';
import { basLineListData } from '/@/api/bas/mes/workline/basLine';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('产线选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: t('产线编码'),
      field: 'code',
      component: 'Input',
    },
    {
      label: t('产线名称'),
      field: 'name',
      component: 'Input',
    },
    {
      label: t('产品编码'),
      field: 'invCode',
      component: 'Input',
    },
    {
      label: t('产品名称'),
      field: 'basInv.cinvname',
      component: 'Input',
      ifShow: false,
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('产线编码'),
    dataIndex: 'code',
    key: 'a.code',
    sorter: true,
    width: 100,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('产线名称'),
    dataIndex: 'name',
    key: 'a.name',
    sorter: true,
    width: 100,
    align: 'left',
  },
  {
    title: t('归属车间'),
    dataIndex: 'basWorkShop.name',
    key: 'a.work_shop_code',
    sorter: true,
    width: 100,
    align: 'left',
  },
  {
    title: t('作业类型'),
    dataIndex: 'jobType',
    key: 'a.job_type',
    sorter: true,
    width: 100,
    align: 'center',
    dictType: 'mes_job_type',
  },
  {
    title: t('产线类型'),
    dataIndex: 'lineType',
    key: 'a.line_type',
    sorter: true,
    width: 100,
    align: 'center',
    dictType: 'mes_line_type',
  },
  {
    title: t('当前订单'),
    dataIndex: 'modid',
    key: 'a.modid',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('当前产品'),
    dataIndex: 'invCode',
    key: 'a.inv_code',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('上机时间'),
    dataIndex: 'upDate',
    key: 'a.up_date',
    sorter: true,
    width: 150,
    align: 'center',
  },
  {
    title: t('最后下机时间'),
    dataIndex: 'downDate',
    key: 'a.down_date',
    sorter: true,
    width: 150,
    align: 'center',
  },
  {
    title: t('产线状态'),
    dataIndex: 'lineStatus',
    key: 'a.line_status',
    sorter: true,
    width: 100,
    align: 'center',
    dictType: 'mes_line_status',
    fixed: 'right',
  },
  {
    title: t('备注说明'),
    dataIndex: 'remarks',
    key: 'a.remarks',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 80,
    align: 'center',
    dictType: 'sys_status',
    fixed: 'right',
  },
  {
    title: t('更新时间'),
    dataIndex: 'updateDate',
    key: 'a.update_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
];

const tableProps: BasicTableProps = {
  api: basLineListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'code',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'code',
  itemName: 'name',
};
